package com.example.Windturbine.Calculation.TreeDOMethod1;

import com.example.Windturbine.Calculation.Method.Method1;
import lombok.AllArgsConstructor;
import lombok.Data;
import org.springframework.beans.BeanUtils;

import java.math.BigDecimal;

/**
 * @Author 丁永新
 * @Date 2021/12/22
 */
@Data
@AllArgsConstructor
public class LCAResult1 implements Method1{

    public Integer id;
    public BigDecimal 煤;
    public BigDecimal 石油;
    public BigDecimal 天然气;
    public BigDecimal co;
    public BigDecimal co2;
    public BigDecimal so2;
    public BigDecimal nox;
    public BigDecimal ch4;
    public BigDecimal h2s;
    public BigDecimal hcl;
    public BigDecimal cod;
    public BigDecimal nh3;
    public BigDecimal cfc11;
    public BigDecimal cfc12;
    public BigDecimal cfc113;
    public Integer calId;

    public BigDecimal PED;
    public BigDecimal GWP;
    public BigDecimal AP;
    public BigDecimal EP;
    public BigDecimal POCP;
    public BigDecimal ODP;
    public BigDecimal greenvalue;

    public LCAResult1() {
        BigDecimal zero=new BigDecimal(0.0);
        this.id = 0;
        this.煤 = zero;
        this.石油 = zero;
        this.天然气 = zero;
        this.co = zero;
        this.co2 = zero;
        this.so2 = zero;
        this.nox = zero;
        this.ch4 = zero;
        this.h2s = zero;
        this.hcl = zero;
        this.cod = zero;
        this.nh3 = zero;
        this.cfc11 = zero;
        this.cfc12 = zero;
        this.cfc113 = zero;
        this.calId = 0;
        this.PED = zero;
        this.GWP = zero;
        this.AP = zero;
        this.EP = zero;
        this.POCP = zero;
        this.ODP = zero;
        this.greenvalue = zero;
    }

    //填补其他数据
    public LCAResult1 cal(){
        LCACalculateProperties1 lcaCalculateProperties=new LCACalculateProperties1();
        LCAResult1 TEMP=new LCAResult1();
        BeanUtils.copyProperties(this,TEMP);
        LCAResult1 lcaResult1 = lcaCalculateProperties.setProperties(TEMP);
        return lcaResult1;
    }


    //LCA相乘运算
    public LCAResult1 multiply(BigDecimal bigDecimal){
        LCAResult1 result=new LCAResult1();
        result.set煤(this.煤.multiply(bigDecimal));
        result.set石油(this.石油.multiply(bigDecimal));
        result.set天然气(this.天然气.multiply(bigDecimal));
        result.setCo(this.co.multiply(bigDecimal));
        result.setCo2(this.co2.multiply(bigDecimal));
        result.setSo2(this.so2.multiply(bigDecimal));
        result.setNox(this.nox.multiply(bigDecimal));
        result.setCh4(this.ch4.multiply(bigDecimal));
        result.setH2s(this.h2s.multiply(bigDecimal));
        result.setHcl(this.hcl.multiply(bigDecimal));
        result.setCod(this.cod.multiply(bigDecimal));
        result.setNh3(this.nh3.multiply(bigDecimal));
        result.setCfc11(this.cfc11.multiply(bigDecimal));
        result.setCfc12(this.cfc12.multiply(bigDecimal));
        result.setCfc113(this.cfc113.multiply(bigDecimal));
        result.setPED(this.PED.multiply(bigDecimal));
        result.setGWP(this.GWP.multiply(bigDecimal));
        result.setAP(this.AP.multiply(bigDecimal));
        result.setEP(this.EP.multiply(bigDecimal));
        result.setPOCP(this.POCP.multiply(bigDecimal));
        result.setODP(this.ODP.multiply(bigDecimal));
        result.setGreenvalue(this.greenvalue.multiply(bigDecimal));
        return result;
    }

    //LCA相加运算
    public LCAResult1 add(LCAResult1 lcaResult1){
        LCAResult1 result=new LCAResult1();
        result.set煤(this.煤.add(lcaResult1.get煤()));
        result.set石油(this.石油.add(lcaResult1.get石油()));
        result.set天然气(this.天然气.add(lcaResult1.get天然气()));
        result.setCo(this.co.add(lcaResult1.getCo()));
        result.setCo2(this.co2.add(lcaResult1.getCo2()));
        result.setSo2(this.so2.add(lcaResult1.getSo2()));
        result.setNox(this.nox.add(lcaResult1.getNox()));
        result.setCh4(this.ch4.add(lcaResult1.getCh4()));
        result.setH2s(this.h2s.add(lcaResult1.getH2s()));
        result.setHcl(this.hcl.add(lcaResult1.getHcl()));
        result.setCod(this.cod.add(lcaResult1.getCod()));
        result.setNh3(this.nh3.add(lcaResult1.getNh3()));
        result.setCfc11(this.cfc11.add(lcaResult1.getCfc11()));
        result.setCfc12(this.cfc12.add(lcaResult1.getCfc12()));
        result.setCfc113(this.cfc113.add(lcaResult1.getCfc113()));
        result.setPED(this.PED.add(lcaResult1.getPED()));
        result.setGWP(this.GWP.add(lcaResult1.getGWP()));
        result.setAP(this.AP.add(lcaResult1.getAP()));
        result.setEP(this.EP.add(lcaResult1.getEP()));
        result.setPOCP(this.POCP.add(lcaResult1.getPOCP()));
        result.setODP(this.ODP.add(lcaResult1.getODP()));
        result.setGreenvalue(this.greenvalue.add(lcaResult1.getGreenvalue()));
        return result;
    }


    public static void main(String[] args) {
        BigDecimal a1=new BigDecimal(1.2);
        BigDecimal a2=new BigDecimal(1.2);
        BigDecimal a3=new BigDecimal(1.2);
        BigDecimal res=a1.add(a2).add(a3).divide(new BigDecimal(3));
        System.out.println(res.toString());
    }
}
